package fourFragment.adapter;

import android.content.Context;
import android.content.Intent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.example.xuegengwang.xuegengwang.R;
import com.makeramen.roundedimageview.RoundedImageView;

import java.util.ArrayList;

import fourFragment.bean.MyFocusVolunteerBean;
import view.MyImageLoader;
import volunteer.activity.Volunteer;

/**
 * Created by Administrator on 2017/4/12.
 */

public class MyFocusVolunteerAdapter extends BaseAdapter {
    private ArrayList<MyFocusVolunteerBean.ExpertListBean> arrayList;
    private Context context;

    public MyFocusVolunteerAdapter(ArrayList<MyFocusVolunteerBean.ExpertListBean> arrayList, Context context) {
        this.arrayList = arrayList;
        this.context = context;
    }

    @Override
    public int getCount() {
        return arrayList.size();
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(final int position, View convertView, ViewGroup parent) {
        MyHolder myHolder;
        if (convertView == null) {
            myHolder = new MyHolder();
            convertView = LayoutInflater.from(context).inflate(R.layout.myfocus_volunteer_item, null);
            myHolder.my_focus_volunteer_item_icon = (RoundedImageView) convertView.findViewById(R.id.my_focus_volunteer_item_icon);
            myHolder.my_focus_volunteer_item_name = (TextView) convertView.findViewById(R.id.my_focus_volunteer_item_name);
            myHolder.my_focus_volunteer_item_title = (TextView) convertView.findViewById(R.id.my_focus_volunteer_item_title);
            myHolder.my_focus_volunteer_item_more = (TextView) convertView.findViewById(R.id.my_focus_volunteer_item_more);
            convertView.setTag(myHolder);
        } else {
            myHolder = (MyHolder) convertView.getTag();
        }
        MyImageLoader.showImage(arrayList.get(position).getHeadimgurl(), myHolder.my_focus_volunteer_item_icon);
        myHolder.my_focus_volunteer_item_name.setText(arrayList.get(position).getName());
        myHolder.my_focus_volunteer_item_title.setText(arrayList.get(position).getBrief());
        String more = arrayList.get(position).getMajor();
        myHolder.my_focus_volunteer_item_more.setText(more);
        return convertView;
    }

    class MyHolder {
        RoundedImageView my_focus_volunteer_item_icon;
        TextView my_focus_volunteer_item_name;
        TextView my_focus_volunteer_item_title;
        TextView my_focus_volunteer_item_more;
    }

}
